<?php

namespace MyBlog\Http\Controllers\desktop;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\View;
use MyBlog\Http\Requests;
use MyBlog\Http\Controllers\Controller;
use MyBlog\Models\Gallery;
use MyBlog\Models\GalleryImg;

class GalleryController extends Controller
{
    public function index() {
        $galleries = Gallery::all();
        return View::make('desktop.galleries', compact('galleries'));
    }

    public function show($id) {
        $gallery = Gallery::find($id);
        return View::make('desktop.gallery', compact('gallery'));
    }
    
    public function img($galleryId, $imgId) {
    	$gallery = Gallery::find($galleryId);
    	$img = GalleryImg::find($imgId);
    	if($img->gallery_id != $gallery->id) {
    		redirect('/404');
    	}
    	return View::make('desktop.gallery_img', compact('gallery', 'img'));
    }
}
